using System;
using System.Collections;
namespace APP.HELPER.Utils.BarcodeLib
{
	internal class Codabar : BarcodeCommon, IBarcode
	{
		private Hashtable Codabar_Code = new Hashtable();
		public string Encoded_Value
		{
			get
			{
				return this.Encode_Codabar();
			}
		}
		public Codabar(string input)
		{
			this.Raw_Data = input;
		}
		private string Encode_Codabar()
		{
			if (this.Raw_Data.Length < 2)
			{
				throw new Exception("ECODABAR-1: Data format invalid. (Invalid length)");
			}
			string text = this.Raw_Data[0].ToString().ToUpper().Trim();
			if (text != null)
			{
				if (!(text == "A"))
				{
					if (!(text == "B"))
					{
						if (!(text == "C"))
						{
							if (!(text == "D"))
							{
								goto IL_88;
							}
						}
					}
				}
				text = this.Raw_Data[this.Raw_Data.Trim().Length - 1].ToString().ToUpper().Trim();
				if (text != null)
				{
					if (!(text == "A"))
					{
						if (!(text == "B"))
						{
							if (!(text == "C"))
							{
								if (!(text == "D"))
								{
									goto IL_10B;
								}
							}
						}
					}
					string text2 = "";
					this.init_Codabar();
					string raw_Data = this.Raw_Data;
					for (int i = 0; i < raw_Data.Length; i++)
					{
						char c = raw_Data[i];
						text2 += this.Codabar_Code[c].ToString();
						text2 += "0";
					}
					text2 = text2.Remove(text2.Length - 1);
					this.Codabar_Code.Clear();
					return text2;
				}
				IL_10B:
				throw new Exception("ECODABAR-3: Data format invalid. (Invalid STOP character)");
			}
			IL_88:
			throw new Exception("ECODABAR-2: Data format invalid. (Invalid START character)");
		}
		private void init_Codabar()
		{
			this.Codabar_Code.Clear();
			this.Codabar_Code.Add('0', "101010011");
			this.Codabar_Code.Add('1', "101011001");
			this.Codabar_Code.Add('2', "101001011");
			this.Codabar_Code.Add('3', "110010101");
			this.Codabar_Code.Add('4', "101101001");
			this.Codabar_Code.Add('5', "110101001");
			this.Codabar_Code.Add('6', "100101011");
			this.Codabar_Code.Add('7', "100101101");
			this.Codabar_Code.Add('8', "100110101");
			this.Codabar_Code.Add('9', "110100101");
			this.Codabar_Code.Add('-', "101001101");
			this.Codabar_Code.Add('$', "101100101");
			this.Codabar_Code.Add(':', "1101011011");
			this.Codabar_Code.Add('/', "1101101011");
			this.Codabar_Code.Add('.', "1101101101");
			this.Codabar_Code.Add('+', "101100110011");
			this.Codabar_Code.Add('A', "1011001001");
			this.Codabar_Code.Add('B', "1010010011");
			this.Codabar_Code.Add('C', "1001001011");
			this.Codabar_Code.Add('D', "1010011001");
			this.Codabar_Code.Add('a', "1011001001");
			this.Codabar_Code.Add('b', "1010010011");
			this.Codabar_Code.Add('c', "1001001011");
			this.Codabar_Code.Add('d', "1010011001");
		}
	}
}
